package main

import (
	"flag"
	"fmt"
	"github.com/russross/blackfriday"
	"io/ioutil"
	"os"
)

func main() {

	flag.Parse()
	// read the input
	var input []byte
	var err error
	args := flag.Args()
	fmt.Println(args)
	switch len(args) {
	case 0:
		fmt.Println("请输入md文件路径")
	case 1, 2:
		if input, err = ioutil.ReadFile(args[0]); err != nil {
			fmt.Fprintln(os.Stderr, "Error reading from", args[0], ":", err)
			os.Exit(-1)
		}
	default:
		flag.Usage()
		os.Exit(-1)
	}

	output := blackfriday.MarkdownBasic(input)
	fmt.Println(string(output))
}
